<form action="/members/login-submit" method="post" name="form1" id="form1">
<div class="am-g dnr">
  <div class="am-u-sm-12"><p><input type="tel" style="border-radius:5px;" class="am-form-field am-radius " placeholder="手机号" name="cellphone" id="cellphone" /></p></div>
  <div class="am-u-sm-12"><p><input type="password" style="border-radius:5px;" class="am-form-field am-radius" placeholder="密码" name="passwd" id="passwd" /></p></div>
  <div class="am-u-sm-12"><p><a href="javascript:void(0);" onclick="checkPhone()">忘记密码</a></p></div>
  <div class="am-u-sm-12"><input type="hidden" name="level3_id" value="<?=$this->level3_id?>" /><button type="button" style=" width:100%;border-radius:5px;" class="am-btn am-btn-primary" onclick="submitform()">登陆</button></div>
</div>
</form>

<script>
function submitform()
{
	if( document.form1.cellphone.value.length == 0 )
	{
		alert("手机号不能为空");
		return false;
	}
	
	if( document.form1.passwd.value.length == 0 )
	{
		alert("密码不能为空");
		return false;
	}
	
	form1.submit();
}

function checkPhone()
{
	var tel = document.getElementById("cellphone").value;
	
	if( document.form1.cellphone.value.length == 0 )
	{
		alert("请填写您的手机号");
		return false;
	}else{
		$.ajax({
			type: "post",
			url : "/ajax/is-cellphone-available",
			dataType:'json',
			data: {'cellphone':tel},
			success: function(json){
				if(json.result == 1){
					alert("您的手机号不存在，请检查是否填写错误");
					return false;
				}else{
					form1.action="/members/forget-password";
					form1.submit();
				}
			}
		});
	}
}
</script>